<template>
  <div class="wap-header" :style="$route.name == 'planting-code' || $route.name == 'sampling' ? 'background: rgba(55, 163, 147, .4);' : 'background: rgba(55, 163, 147, 1);'">
    <van-icon name="arrow-left" @click="goBack()" :class="$route.name == 'planting-code' ? 'left-icon' : ''"/>
    <span>{{routerTitle}}</span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      routerTitle: this.$route.meta.title,
    };
  },
  mounted() {},
  methods: {
    goBack() {
        window.history.back()
    },
  },
  watch: {
    $route() {
      this.routerTitle = this.$route.meta.title;
    },
  },
};
</script>

<style scoped>
.wap-header {
  width: 100%;
  height: 45px;
  background: #39ad97;
  background: rgba(55, 163, 147, 1);
  display: flex;
  align-items: center;
  padding: 0 60px 0 0;
  box-sizing: border-box;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
}
.wap-header i {
  display: block;
  font-size: 20px;
  color: #fff;
  height: 45px;
  line-height: 45px;
  padding:0 20px;
}
.wap-header span {
  font-size: 18px;
  color: #fff;
  flex: 1;
  text-align: center;
}
.left-icon {
  visibility: hidden;
}
</style>
